Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Core java - Interview Questions and Answers for 'Nagarro' - 2 question(s) found - Order By Newest | ||||
| ||||
Ans. 1. Overriding method can not be more restrictive than the overridden method. reason : in case of polymorphism , at object creation jvm look for actual runtime object. jvm does not look for reference type and while calling methods it look for overridden method. If by means subclass were allowed to change the access modifier on the overriding method, then suddenly at runtime when the JVM invokes the true objects version of the method rather than the reference types version then it will be problematic 2. In case of subclass and superclass define in different package, we can override only those method which have public or protected access. 3. We can not override any private method because private methods can not be inherited and if method can not be inherited then method can not be overridden. | ||||
Sample Code for Overriding | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   overriding   access specifier   inheritence   oops   polymorphism  object oriented programming (oops)  oops concepts   runtime polymorphism  object oriented programming (oops)  oops concepts Asked in 4 Companies | ||||
Try 2 Question(s) Test | ||||
Related Questions | ||||
Difference between Overloading and Overriding ? | ||||
Any real life example of Overloading and Overridding ? | ||||
How compiler handles the exceptions in overriding ? | ||||
what is covariant return type? | ||||
Overridden methods must have the same ... | ||||
What is a Final Method ? | ||||
Can we reduce the visibility of the inherited or overridden method ? | ||||
How does java identifies which method to be called in method overriding or runtime polymorphism, when both methods share the same name and signature ? | ||||
Can we reduce the visibility of the overridden method ? | ||||
| ||||
Ans. Everytime an object is serialized the java serialization mechanism automatically computes a hash value by passing the meta information for the class. This id is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  serialVersionUID  serialization Asked in 3 Companies expert   rare | ||||
Related Questions | ||||
What is Serialization ? Why do we need it ? | ||||
Can we declare static variables as transient ? | ||||
Which elements of a class are ignored during serialization ? | ||||
Can we serialize static variables ? | ||||
What one should take care of, while serializing the object? | ||||
What is the use of Transient Keyword ? | ||||
serialization and deserialization of singleton class | ||||
Difference between Serialization and Deserialization ? | ||||
What is an Externalizable interface ? | ||||
Difference between serializable and externalizable interface ? | ||||